<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>{% block title %}{% endblock %}</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script src="{{ MEDIA_URL }}/js/jquery-1.6.2.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="{{ MEDIA_URL }}/js/jquery-ui-1.8.16.custom.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="{{ MEDIA_URL }}/js/jquery.form.js" type="text/javascript" charset="utf-8"></script>
	<script src="{{ MEDIA_URL }}/js/jquery.jgrowl_minimized.js" type="text/javascript" charset="utf-8"></script>
	<link type="text/css" rel="stylesheet" href="{{ MEDIA_URL }}/css/custom-theme/jquery-ui-1.8.16.custom.css" />
	<link type="text/css" rel="stylesheet" href="{{ MEDIA_URL }}/css/jquery.jgrowl.css" />
	<link type="text/css" rel="stylesheet" href="{{ MEDIA_URL }}/css/base.css" />
	{% load setting %}

	<script type="text/javascript">
		function form_styling() {
			$("table.form td").addClass("bottom-valign");
			$("table.form th").addClass("bottom-valign right-align");
			$('td.bottom-valign br').remove();
			$('ul.errorlist li').each(function() {
				replace = '<div class="ui-state-error ui-corner-all"><p class="ui-state-margins"><span style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-alert"></span>';
				replace += $(this).text();
				replace += '</p></div>';
				$(this).replaceWith(replace);
			});
			$('ul.errorlist').each(function() {
				$(this).replaceWith($(this).contents());
			});
		}
	
		$(function() {
			$(this).ajaxError(
				function(e, jqxhr, settings, exception) {
					if(settings.url != "/ajax-error/") {	
						msg =  "<strong>Oops! Your last request failed.</strong> Please try again. If the error still occurs, the administrator of this website has been notified, so we'll fix it as soon as possible.";
						$.jGrowl(msg, { theme: 'ui-state-error', life: 10000 });

						info = "event: " + JSON.stringify(e, null, 4);
						info += "\nXHR: " + JSON.stringify(jqxhr, null, 4);
						info += "\nsettings: " + JSON.stringify(settings, null, 4);
						info += "\nexception: " + JSON.stringify(exception, null, 4);
						console.log(info);
						$.post(
								"/ajax-error/",
								{'errordata': info}
						);
						$('.loading').remove();
					}
				});

			$("input.datepicker").datepicker();
			$( ".button" ).button();
			$('#tabs').tabs();
			form_styling();
		});
	</script>
	<script type="text/javascript">
	{% block scriptblock %}{% endblock %}
	</script>

	{% block headblock %}{% endblock %}

</head>
<body>
<div class="wrapper">
	<div class="ui-widget ui-widget-header ui-state-active ui-corner-all top-user-bar">
		<div class="top-user-bar-left">
			{% if user.username %}
				You are logged in as <span style="font-weight: bold">{{ user.username }}</span> 
				( <a href="{% url django.contrib.auth.views.logout_then_login %}">Logout</a> / 
				<a href="{% url django.contrib.auth.views.password_change %}">Change Password</a>
				{% load userfilters %}
				{% if user|is_faculty_sponsor %} / <a href="/school/{{ user.faculty_sponsor.school.url_name }}">Home</a>{% endif %}
				)
			{% else %}
				<a href="{% url django.contrib.auth.views.login %}?next={{ request.path }}">Login</a> / 
				<a href="/accounts/register/?next={{ request.path }}">Register</a>
			{% endif %}
		</div>
		<!-- <div class="top-user-bar-right">
			<small>
			Please be patient - we are still developing this site! If you experience issues, email <a href="mailto:registration@ctmun.org">registration@ctmun.org</a>
			</small>
		</div> -->
	</div>
	
	<noscript>
	<div class="ui-widget ui-state-error ui-corner-all no-javascript">
		<p>
		<span style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-alert"></span>
		You do not have Javascript enabled in your web browser. Please enable Javascript before using this site.
		</p>
	</div>
	</noscript>
	
	<div class="container">
		{% block content %}{% endblock %}
	</div>
</div>

</body>
</html>
